<template>
  <div :class='{"ad-level":true,isChecked:searchInfo.cate==1}'>
    <Search :search="searchInfo" @new_search="getSearch" />
    <MyNav :search="searchInfo" :getListData="getListData" :pageInfo="pageInfo" />
    <List :listData="listData" @forMore="getMoreInfo">
      <ListModel :search="searchInfo" :listData="listData" :routerDetail="routerDetail" />
    </List>
    <div v-show="searchInfo.cate==1" class="btn-box"><van-button type="primary" class="bc-green" @click="submit" >确定</van-button></div>
  </div>
</template>
<script>
import Search from '../../../../components/search.vue'
import MyNav from './model/nav.vue'
import MixIns from '../../../../mixin/mixin.js'
import List from '../../../../components/list.vue'
import ListModel from "./model/list.vue"
export default {
  components: {Search,MyNav,List,ListModel},
  name: "",
  data() {
    return {
      searchInfo:{
        keyword:"",
        cate:"1"
      },
    };
  },
  methods: {
    getSearch(){
      this.searchInfo.keyword=this.searchInfo.search
      this.pageInfo.page=1
      this.getListData()
    },
    submit(){
      var params={
        pass:[],
        nopass:[]
      }
      this.listData.forEach(ele=>{
        params[ele.isPassed?"pass":"nopass"].push(ele.id)
      })
      params.pass=params.pass.join(",")
      params.nopass=params.nopass.join(",")

      _g.apiPost("attendance/confirmLeave",params).then(res=>{
        _g.toMessage(res)
        if(!res.error){
          this.pageInfo.page=1
          setTimeout(()=>{
            this.getListData()
          },600)
        }
      })
    }
  },
  created() {},
  mixins:[MixIns]
};
</script>
<style lang="scss" scoped>
.ad-level {
  height: 100%;
  .btn-box{
    padding: 20px;
    box-shadow: 0px -2px 2px 0px #ddd;

    .bc-green{
      width: 100%;
    }
  }
}
</style>